<template>
	<view class="indexs">
		<view :class="'header ' + (banertrue ? 'header_lan' : '')" :style="'padding-top: ' + navH + 'px;'">
			<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
				<view class="index_h_cont3">
					<view class="index_wenben_img" @tap="jumpzuo"><image :src="imgUrl + '/dzx_img22.png'" mode="widthFix"></image></view>
					<view class="index_wenben baise">{{ $t('page_shenqingdb_renling.package_claim') }}</view>
				</view>
			</view>
			<view class="coloe_title">s</view>
		</view>
		<view class="index_banner" style="position: absolute; top: 0; width: 100%; left: 0"><image :src="imgUrl + '/dzx_img39.png'" mode="widthFix"></image></view>
		<view class="index_center" :style="'padding-top:' + (navH + 50) + 'px;'">
			<view class="baoguo_renling">
				<view class="baoguo_renling_top">
					<view class="baoguo_renling_inputs">
						<image :src="imgUrl + '/dzx_img38.png'"></image>
						<input type="text" :placeholder="$t('page_other.请输入快递单号')" @confirm="huiche" />
					</view>
				</view>
				<view class="baoguo_renling_bottom" v-if="arrlist.length != 0">
					<view class="baoguo_renling_list">
						<view class="baoguo_renling_cont" v-for="(item, index) in arrlist" :key="index">
							<view class="baoguo_renling_cont_top">
								<view class="baoguo_renling_l">
									<image :src="imgUrl + '/dzx_img27.png'"></image>
									<view class="baoguo_renling_txt">
										<view class="baoguo_renling_t1">
											{{
												$t('page_shenqingdb_renling.parcel_no', {
													num: item.express_num
												})
											}}
											
										</view>
										<view class="baoguo_renling_t2">
											{{ $t('page_shenqingdb_renling.storage_time') }}：
											<text>{{ item.entering_warehouse_time ? item.entering_warehouse_time : $t('page_shenqingdb_renling.not_yet_storage') }}</text>
										</view>
									</view>
								</view>
								<view class="baoguo_renling_r" @tap="baoguorenling" :data-id="item.id">{{ $t('page_shenqingdb_renling.claim') }}</view>
							</view>
							<view class="baoguo_renling_2" v-if="item.packageimage.length > 0 && setting.is_ren_image == 1">
								<a
									@click="clickImg"
									:data-url="items.file_path"
									:data-id="item.id"
									:href="items.file_path"
									v-for="(items, index) in item.packageimage"
									:key="index"
									class="imagelink"
								>
									<image :src="items.file_path"></image>
								</a>
							</view>
						</view>
					</view>
				</view>
				<view class="baoguo_renling_bottom" style="background: #fff" v-else>
					<view class="my_dingdan_zanwu">
						<image :src="imgUrl + '/dzx_img43.png'"></image>
						<text>{{ $t('page_shenqingdb_renling.no_package_yet') }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
// pages/shouye/shouye_zkc/shouye_zkc.js
const app = getApp();

let request = require('../../../utils/require');

export default {
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData.top,
			imgUrl: app.globalData.imgUrl,
			banertrue: false,
			setting: uni.getStorageSync('setting'),
			//分页
			page: 1,
			ispage: true,
			arrlist: []
		};
	}, //滑动显示顶部
	onPageScroll: function(e) {
		if (e.scrollTop > this.navH + 50) {
			this.banertrue = true
		} else {
			this.banertrue = false
		}
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad() {
		var that = this;
	},
	onShow() {
		var that = this;
		that.page = 1
		that.ispage =  true
		that.arrlist = []
		that.baoguorenlinglist();
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {
		console.log('6666');
		if (this.ispage) {
			this.page = this.page + 1
			this.baoguorenlinglist(this.type);
		}
	},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {},
	methods: {
		huiche(e) {
			var that = this;
			that.page = 1
			that.arrlist= []
			that.ispage = true
			var data = {
				token: uni.getStorageSync('token'),
				page: that.page,
				keyword: e.detail.value
			};
			request.post(`index.php?s=/api/package/packageForTaker&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					if (that.page > res.data.data.last_page) {
						that.ispage = false
					} else {
						that.arrlist = that.arrlist.concat(res.data.data.data)
					}
				}
			});
		},

		baoguorenlinglist() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token'),
				page: that.page
			};
			request.post(`index.php?s=/api/package/packageForTaker&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					if (that.page > res.data.data.last_page) {
						that.ispage = false
					} else {
						that.arrlist = that.arrlist.concat(res.data.data.data)
					}
				}
			});
		},

		baoguorenling(e) {
			uni.navigateTo({
				url: '/pages/indexs/shenqingdb_renling_details/shenqingdb_renling_details?id=' + e.currentTarget.dataset.id
			});
		},

		jumpzuo() {
			uni.navigateBack();
		},
		clickImg(e) {
			wx.previewImage({
				urls: [e.currentTarget.dataset.url],
				current: '',
				success: function(res) {},
				fail: function(res) {},
				complete: function(res) {}
			});
		}
	}
};
</script>
<style>
@import './shenqingdb_renling.css';
</style>
